package com.salt.modules.sys.feign;

import com.salt.common.constant.Common;
import com.salt.common.utils.StringUtils;
import com.salt.core.web.BaseController;
import com.salt.modules.sys.entity.Area;
import com.salt.modules.sys.service.AreaService;
import com.salt.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author salt
 * @Date 2020/7/29 17:34
 * @Version 1.0
 */
@RestController
@RequestMapping(Common.Service.SALT_ADMIN_AREA_URL_PREFIX)
public class AreaFeignController extends BaseController {

    @Autowired
    private AreaService areaService;

    @PostMapping("getById")
    public Area get(@RequestParam(required = false) String id){
        if (StringUtils.isNotBlank(id)){
            return areaService.get(id);
        }else{
            return new Area();
        }
    }

    @PostMapping("getByName")
    public Area getByAreaName(@RequestParam("name") String name){
        return UserUtils.getByAreaName(name);
    }
}
